package com.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sfzy.entity.Carousel;
import com.sfzy.mapper.CarouselMapper;
import com.sfzy.service.CarouselService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CarouselServiceImpl implements CarouselService {
    @Autowired
    private CarouselMapper carouselMapper;
    @Override
    public int addCarousel(Carousel carousel) {
        return carouselMapper.addCarousel(carousel);
    }

    @Override
    public int deleteCarousel(int id) {
        return carouselMapper.deleteCarousel(id);
    }

    @Override
    public int updateCarousel(Carousel carousel) {
        return carouselMapper.updateCarousel(carousel);
    }

    @Override
    public Carousel getCarouselById(int id) {
        return carouselMapper.getCarouselById(id);
    }

    @Override
    public PageInfo<Carousel> getAllCarousel(Carousel carousel, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Carousel> allCarousel = carouselMapper.getAllCarousel(carousel);
        PageInfo<Carousel> pageInfo = new PageInfo<>(allCarousel);
        return pageInfo;
    }
}
